<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta content="test/html" charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1"/>

    <title>Spring_Cloud_Test</title>
</head>
<body>
    <h2>Hello World!${msg}</h2>
    <br/>
    <span id="userInfo" class="check-required">&nbsp;</span>
    <br/>
    <button id="Spring_Cloud_Test" type="button" onclick="getUserInfo();">Spring Cloud Test</button>
    <button id="Spring_Cloud_Test_Stop" type="button" onclick="stopTest();">Spring Cloud Test Stop</button>

    <script th:inline="javascript">
        var id = 0;
        var testSwitch = false;

        function getUserInfo() {
            testSwitch = true;
            while(true){
                if(testSwitch){
                    id ++;
                    $.ajax({
                        type: "POST",
                        dataType: "json",
                        async:false,
                        url: ${pageContext.request.contextPath}+"/consumerBeehive/"+id,
                        data:{},
                        success: function(data){
                            $("#userInfo").html(data);
                        },
                        error : function (xhr,errorMsg,ex){
                            alert( "获取用户信息异常  ： "+ex );
                        }
                    });
                }else{
                    break;
                }
            }

        }

        function stopTest() {
            testSwitch = false;
        }
    </script>
</body>
</html>
